package com.training.java.core.homework07.collections.sets;

import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

public class LaptopForTreeSetDemo {

	public static void main(String[] args) {

		/*
		 * This program builds a TreeSet of Laptop objects.
		 */

		// Create LaptopForDupChk objects with a few duplicates.
		LaptopForTreeSet presario = new LaptopForTreeSet("HP", "Presario", 4,
				100);
		LaptopForTreeSet pavilion = new LaptopForTreeSet("HP", "Pavilion", 6,
				200);
		LaptopForTreeSet presario2 = new LaptopForTreeSet("HP", "Presario", 6,
				200);
		LaptopForTreeSet lenovo = new LaptopForTreeSet("IBM", "Lenovo", 4, 200);
		LaptopForTreeSet pavilion2 = new LaptopForTreeSet("HP", "Pavilion2", 10,
				800);

		// Check for equality:
		int laptopCompareTo;
		laptopCompareTo = presario.compareTo(pavilion);
		System.out.println("How do they compare? " + laptopCompareTo);

		laptopCompareTo = presario.compareTo(lenovo);
		System.out.println("How do they compare? " + laptopCompareTo);

		laptopCompareTo = lenovo.compareTo(presario);
		System.out.println("How do they compare? " + laptopCompareTo);

		Set<LaptopForTreeSet> laptops = new TreeSet<>(); // Create Treeset to hold Laptop objects

		// Add Laptop objects to TreeSet laptops.
		laptops.add(presario);
		laptops.add(pavilion);
		laptops.add(presario2);
		laptops.add(lenovo);
		laptops.add(pavilion2);

		System.out.println("");
		System.out.println("Printing laptops:");
		System.out.println("=================");
		
		for (LaptopForTreeSet laptop : laptops) {
			System.out.println("Manufacturer = " + laptop.getManufacturer());
			System.out.println("Model = " + laptop.getModel());
			System.out.println("Memory = " + laptop.getMemory());
			System.out.println("Disk Capacity = " + laptop.getDiskCapacity());
			System.out.println("---------------------------------------");
		}
	}
}
